import axios from 'axios'

const FetchGoodsItem = ({page, size}) => {
  return  axios.get('http://47.101.45.245:7005/api/findGoods')
}


export default {
  namespace: 'goods', // 命名空间 （调用函数的依据）
  state: {
    goodsList: []
  }, // 数据仓库
  effects: {// 副作用解决  vue action  thunk  redux-saga -- generator *
    *getGoods({data}, { call, put }) { // call 调用接口方法  put 类似于dispatch
      console.log('参数....:', data)
      const response = yield call(FetchGoodsItem, {...data})
      yield put({
        type: 'setGoods',
        data: response.data.data
      })
      return {data: response.data.data}
    }
  },
  reducers: {
    setGoods(state, action) {// 纯函数  vue muation
      state.goodsList = action.data
      return {...state}
    }
  },
}